{extend name="./tpl/default/mobile/public/layout.html" /}
{block name="header"}
<link rel="stylesheet" href="/public/home/mobile/css/guanjian/anli.css">
<link rel="stylesheet" href="/public/home/mobile/css/guanjian/gonglv.css">
<link rel="stylesheet" href="/public/home/mobile/css/guanjian/shouhuodizhi.css">
<style>
    .am-header-default{
        background-color: #fff;
    }
</style>
{/block}
{block name="head"}
<header data-am-widget="header"
        class="am-header am-header-default">
    <div class="am-header-left am-header-nav" onclick="history.back(-1)">
        <span class="icon iconfont icon-xiangzuojiantou" style="color: #989898;"></span>
    </div>

    <h1 class="am-header-title" style="color:#424242;">
        添加收货地址
    </h1>

    <div class="am-header-right am-header-nav">
        <a href="{:url('search')}"><span class="icon iconfont icon-sousuo" style="color: #989898;"></span></a>
    </div>
</header>
<hr style="border:1px solid #e0e0e0;margin: 0px;">
{/block}
{block name="body"}
<div class="am-g" style=" overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
    <form action="" id="form">
        {notempty name='info'}
        <input type="hidden" name="address_id" value="{$info.address_id}">
        {/notempty}
        <div class="am-u-sm-12">
            <div class="am-form-group" style="margin-top: 30px;">
                <label for="name">姓名</label>
                <input type="text" class="" id="name" name="consignee" value="{$info.consignee}" placeholder=""
                       style="margin-left: 15px;width: 300px;">
            </div>
        </div>
        <div class="am-u-sm-12">
            <div class="am-form-group">
                <label for="zip-code">邮编</label>
                <input type="email" class="" id="zip-code" name="zip_code" value="{$info.zip_code}" placeholder=""
                       style="margin-left: 15px;width: 300px;">
            </div>
        </div>
        <div class="am-u-sm-12">
            <div class="am-form-group">
                <label for="tel">电话</label>
                <input type="email" class="" id="tel" name="tel_phone" value="{$info.tel_phone}" placeholder=""
                       style="margin-left: 15px;width: 300px;">
            </div>
        </div>
        <div class="am-u-sm-12" style="margin-bottom: 0px;">
            <div class="am-form-group">
                <label for="area">地区</label>
                <div class="area_name" id="area" style="margin-left: 58px;
                                                            width: 300px;
                                                            margin-bottom: -11px;
                                                            margin-top: -33px;">
                    <select id="prov_id" name="prov_id" class="form-control"></select>
                    <select id="city_id" name="city_id" class="form-control"></select>
                    <select id="dist_id" name="dist_id" class="form-control"></select>
                </div>
                <span class="am-form-caret"></span>
            </div>
        </div>
        <div class="am-u-sm-12" style="margin-top: 15px;">
            <div class="am-form-group">
                <label for="address">地址</label>
                <input type="email" class="" id="address" name="address" value="{$info.address}" placeholder=""
                       style="margin-left: 15px;width: 300px;">
            </div>
        </div>
        <div class="am-u-sm-12">
            <div class="am-form-group">
                <label for="doc-select-1">默认</label>
                <select id="doc-select-1" name="is_default" style="margin-left: 15px;width: 300px;">
                    <option value="0" {eq name="info.is_default" value="0" } selected {/eq}>否</option>
                    <option value="1" class="am-checkbox" {eq name="info.is_default" value="1" } selected {/eq}
                    {empty name='info'} selected {/empty}
                    >是</option>
                </select>
                <span class="am-form-caret"></span>
            </div>
        </div>
        <div class="am-u-sm-12">
            <button type="button" onclick="addAddress()" class="am-btn am-btn-default">提交</button>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script src="/public/plugins/jsAddress/jsAddress.js"></script>
<script src="/public/plugins/json2.js"></script>
<script>
    {empty name='info'}
        addressInit('prov_id', 'city_id', 'dist_id');
    {else/}
        addressInit('prov_id', 'city_id', 'dist_id',"{$info.prov_id}","{$info.city_id}","{$info.dist_id}");
    {/empty}
    function addAddress() {
        var data=$('#form').serialize();
        $.post('{:url("/home/User/addressAdd")}',data,function (data) {
            layer.open({
                content: data.msg
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
                ,end:function () {
                    if (data.code){
                        location.href=data.url;
                    }
                }
            });
        })
    }
</script>
{/block}
